package com.cater.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cater.common.BaseEntity;
import com.cater.common.PageResult;
import com.cater.query.CommonQuery;
import com.cater.sys.dao.UserCollectionDao;
import com.cater.sys.entity.UserCollection;
import com.cater.sys.service.BaseService;

/**
 * @author 作者: sd
 *  @商品绑定节点
 * @version 1.0
 */
@Service
public class UserCollectionServiceImpl implements BaseService<UserCollection, CommonQuery, String> {

	@Autowired
	private UserCollectionDao dao;

	@Override
	public PageResult<UserCollection> findPageResult(CommonQuery query) {
		PageResult<UserCollection> result = new PageResult<UserCollection>();
		result.setPage(query.getPage());
		result.setPageSize(query.getRows());
		int count = dao.findCount(query);
		int first = (query.getPage() - 1) * query.getRows();
		int max = query.getRows();
		List<UserCollection> list = dao.findList(query, first, max);
		result.setRows(list);
		result.setRecords(count);
		return result;
	}

	@Override
	public List<UserCollection> getAll() {
		return dao.getAll();
	}

	@Override
	public List<UserCollection> getAllCommon(CommonQuery query) {
		return dao.getAllCommon(query);
	}

	@Override
	public int save(UserCollection t) {
		BaseEntity.getCreate(t);
		return dao.save(t);
	}
	
	@Override
	public void update(UserCollection t) {
		BaseEntity.getupdate(t);
		dao.update(t);
	}

	public void delete(String userid,String nodeid) {
		dao.deletes(userid,nodeid);
	}


	@Override
	public void delete(String id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public UserCollection getById(String id) {
		return dao.getById(id);
	}
	
	public UserCollection getByUserAndNode(String userid,String nodeid){
		return dao.getByUserAndNode(userid, nodeid);
	}

	@Override
	public String saves(UserCollection t) {
		// TODO Auto-generated method stub
		return null;
	}
}
